﻿using System;
using System.Net;
using System.Runtime.InteropServices;
using MySql.Data.MySqlClient;

namespace WindowsApplication1
{
    public class FactoryJsonResult_class
    {
        public string FormulaName { get; set; }//配方的名字
        public string ClusterCellNum { get; set; }//簇总单体电芯数量
        public string AfeCellNum { get; set; }//1个afe芯片监测的电芯数量
        public string PackNum { get; set; }//bmu 从板的数量
        public string BMUCellNum { get; set; }//bmu 监测单体电芯的数量
        public string BMUAfeNum { get; set; }//bmu中afe芯片的数量
        public string SWVersion { get; set; }//软件版本号
        public string HWVersion { get; set; }//硬件版本号
        public string SNNum { get; set; }//产品sn码

    }
    public class FaultJsonResult_class//标定故障信息   ,
    {
        public string Name { get; set; }//故障阈值的名字位
        public string SignalNum { get; set; }//自定义协议的编号
        public string Val { get; set; }//初值
        public string Unit { get; set; }//单位
        public string Min { get; set; }//最小值
        public string Max { get; set; }//最大值
        public string Comment { get; set; }//注释
        public string Operation { get; set; }//操作

    }
    class MyDefine
    {
        public enum BootState_E
        {
            BS_NULL,
            BS_FAIL,//失败
            BS_SUCCEED,//boot成功
            BS_SILENT,//进入静默模式
            BS_START,//开始
            BS_FileSize,//发送固件大小和校验
            BS_Erasechip,//擦除flash
            BS_SANDBIN,//发送固件
            BS_CHECKBIN//校验固件   
        }
        public enum CANCOM_E //上位机与bmu 自定义协议,指令
        {
            BC_Assignaddr_PC = 0xE4,
            BC_Assignaddr_BMU = 0xE5,//
            BS_Check_PC = 0xE6,//
            BS_Check_BMU = 0xE7,//
            BS_ShakeHand_PC = 0xE8,//
            BS_ShakeHand_BMU = 0xE9   
        }
        public enum CANCRC32INIT_E //上位机与bmu 自定义协议,CRC32 初始值
        {
            BMU_BOOT = 0,
            BCI_Assignaddr_PC = 0x1956,
            BSI_ShakeHand_BMU = 0x3356,
            BSI_Check_BMU = 0x3924,
            BSI_Check_PC = 0x4628,
            BSI_ShakeHand_PC = 0x5648,
            BCI_Assignaddr_BMU = 0x6121
        }
        [StructLayout(LayoutKind.Explicit, Size = 8, CharSet = CharSet.Ansi)]
        public class Flag
        {
            [FieldOffset(0)] public byte SlaveModeSend;
            [FieldOffset(1)] public byte SlaveModeAck;
            [FieldOffset(2)] public byte SlaveCheckSend;
            [FieldOffset(3)] public byte SlaveCheckAck;
            [FieldOffset(4)] public byte SlaveAddrSend;
            [FieldOffset(6)] public byte SlaveAddrAck;
            [FieldOffset(7)] public byte SlaveModeStart;
        };
        public struct FaultlogState_s
        {
            public bool nvmCheckSend;
            public bool nvmCheckAck;
            public bool nvmInfoSend;
            public bool nvmInfoAck;

            public bool nvmMessageStart;//true 开始  false 结束
            public bool nvmMessageSend;    
            public int nvmMessageMax; 
            public int nvmMessageNub;
            public int nvmMessageCnt;
            public int nvmPackLength;
            public int nvmPackCrc32;
            public int nvmPackCnt;
            public int nvmErrorCode;

            public bool tfCheckSend;
            public bool tfCheckAck;

            public bool tfMessageStart;
            public bool tfMessageSend;
            public int tfTimeStamp;
            public int tfPackLength;
            public int tfPackCnt;
            public int tfPackCrc32;
            public int tfErrorCode;//1 握手失败 ; 2 CRC8 失败 ; 3 CRC32 失败

        };
        public struct BOOTDATA_s
        {
            public BootState_E State;//0 待机;1 失败 ;2  完成;3 开始 ;4 file size & crc32 ;5 擦除Fash ;6 传输数据到备份区 ;7 校验中; 8 备份区->app
            public uint FirmwareSize;//固件大小
            public uint CrcSize;//大小校验
            public byte FirmwareVersion;//固件版本
            public byte FirmwareType;//固件类型
            public uint PageIndex;//页序号
            public uint CrcPage;//大小校验
            public uint CmdID;//节点设备的ID地址
            public uint DataID;//节点设备的ID地址
            public long TimeSpanStart;//固件开始升级的时间戳
            public long TimeSpanOpt;//操作的时间戳
            public byte Ack;
            public byte OutTime;
            public byte ErrorCnt;//错误次数 :超时错误 , 应答错误
            public byte Order;
            public byte SendDataStep;
            public float progress;
        };

        /*博最科技DBC*/
        public enum DBC_ID
        {
            BMS_InitState = 0x61,
            BMS_OtherSup = 0x62,
            BMS_PowerSup = 0x63,
            BMS_PackVolt = 0x64,
            BMS_Current = 0x65,
            BMS_BattContLight_Sts = 0x66,
            BMS_EnvirTemp = 0x67,
            BMS_EnvirTempMaxMin_Shunt = 0x68,
            BMS_BMCTemp_CSCMaxMin = 0x69,
            BMS_ContactorSup1 = 0x6A,
            BMS_ContactorSup2 = 0x6B,
            BMS_DiagVolt = 0x6C,
            BMS_HSDVolt = 0x6D,

            BMS_CellVolt001 = 0x101,
            //BMS_CellVolt002 -- BMS_CellVolt025
            BMS_CellVolt026 = 0x11A,

            BMS_CellVolt027_Avg = 0x11B,
            BMS_CellVoltMaxMin1 = 0x11C,
            BMS_CellVoltMaxMin2 = 0x11D,
            BMS_CellVoltMaxMin3 = 0x11E,

            BMS_AFEVolt01 = 0x171,
            //BMS_AFEVolt02 -- BMS_AFEVolt07
            BMS_AFEVolt08 = 0x178,

            BMS_AFEVoltMaxMin = 0x179,
            BMS_FaultInfomation1 = 0x1A0,
            BMS_FaultInfomation2 = 0x1A1,
            EOL_Test = 0x1A2,
            EOL_State = 0x1A3,
            BMS_GBWARNINGINFO1 = 0X1B0,
            BMS_GBWARNINGINFO2 = 0X1B1,
            BMS_InletTempMaxMinAvg = 0x1D1,
            BMS_OutletTempMaxMinAvg = 0x1D2,

            BMS_PCB_Temp1 = 0x1D3,
            //BMS_PCB_Temp2 -- BMS_PCB_Temp6
            BMS_PCB_Temp7 = 0x1D9,


            BMS_AFE_Temp1 = 0x1E1,
            //BMS_AFE_Temp2 -- BMS_AFE_Temp7
            BMS_AFE_Temp8 = 0x1E8,

            BMS_AFE_TempMaxMin = 0x1E9,
            BMS_SOX = 0x201,
            BMS_DTC_Isolation = 0x202,
            BMS_RTC = 0x204,
            BMS_Version = 0x205,
            BMS_FAN_States = 0x206,
            BMS_ID = 0x209,

            BMS_ClusterTemp01 = 0x20A,
            //BMS_ClusterTemp02 -- BMS_ClusterTemp14
            BMS_ClusterTemp15 = 0x218,

            BMS_ClusterType_DiffAvg = 0x219,
            BMS_CluTempMaxMin1 = 0x21A,
            BMS_CluTempMaxMin2 = 0x21B,
            BMS_CluTempMaxMin3 = 0x21C,

            BMS_Read_Type = 0x260,
            BMS_Time = 0x261,
            BMS_SingleCap_Erg = 0x262,
            BMS_TotalCapacity = 0x263,
            BMS_TotalEnergy = 0x264,
            BMS_PCB_Temp8 = 0x2D1,
            CAB500_CAN_3C2 = 0x3C2,
            Test_BMS_BSWDebugFr = 0x444,
            XCP_Tx = 0x600,
            XCP_Rx = 0x601,
            BMS_Calibration1 = 0x602,
            DV_BMS_Cell_BALA_FB = 0x603,
            DV_EOL_BALA_COMM = 0x604,     
            BMS_CELLVOLMIN = 0X702,// 0X702 延续,共128个
            BMS_CELLTEMPMIN = 0X796,// 0X796 延续,共64个
            BMS_CELLBALAMIN = 0X7E0,// 0X7E0  延续,共7个
            BCUBOOTDATAID = 0x7F8,    // BOOT CMD PC & BCU
            BCUBOOTCMDID = 0x7F9,//BOOT DATA PC & BCU
            FAULTLOG_Double = 0X7FA,//读故障日志:多帧: BCU & PC
            FAULTLOG_Single = 0X7FB,    //读故障日志:单帧: BCU -> PC
            CLB_CANID = 0X7FC,//标定与控制
            INSLAVEMODE =  0X7FE,    //BMU模式通讯: PC & BMU  ;
        }
        public struct clb_facinfo_t
        {
            //-------需要存入flash 10 个变量 ---------
            public UInt16 ClusterCellNum;//簇电芯数量
            public UInt16 AfeCellNum;//afe电芯数量
            public UInt16 PackNum;//从板数量
            public UInt16 BMUCellNum;//备用
            public UInt16 BMUAfeNum;
            public UInt16 SWVersion;
            public UInt16 HWVersion;
            public UInt16 SNNum;
            public UInt16 Test6;
            public UInt16 Test7;
            //-------下面的不需要存入flash---------
            public UInt32 crc32;
            public byte checksucceed;//握手成功标志位
        };
        public struct DBC_BZ_s //结构体,包含BZ的DBC协议里除数组中所有内容(变量)
        {

            public byte AFE_Num;
            public byte AFE_Num_Res;
            public byte BmbalanceError;
            public byte BMBusbarOT1;
            public byte BMBusbarOT2;
            public byte BMBusbarOT3;
            public byte BMCanHallError;
            public byte BMCanHallOutRange;
            public byte BMCanHallZeroError;
            public byte BMCanSensorError;
            public byte BMCellDiff1;
            public byte BMCellDiff2;
            public byte BMCellDiff3;
            public byte BMCellOV1;
            public byte BMCellOV2;
            public byte BMCellOV3;
            public byte BMCelltempOverDiff1;
            public byte BMCelltempOverDiff2;
            public byte BMCelltempOverDiff3;
            public byte BMCellUV1;
            public byte BMCellUV2;
            public byte BMCellUV3;
            public byte BMChgCellOT1;
            public byte BMChgCellOT2;
            public byte BMChgCellOT3;
            public byte BMChgCellUT1;
            public byte BMChgCellUT2;
            public byte BMChgCellUT3;
            public byte BMChgOverCur1;
            public byte BMChgOverCur2;
            public byte BMChgOverCur3;
            public byte BMCluOV1;
            public byte BMCluOV2;
            public byte BMCluOV3;
            public byte BMCluUV1;
            public byte BMCluUV2;
            public byte BMCluUV3;
            public byte BMCommError;
            public byte BMContactorPowError;
            public byte BMContactorPowErrorHigh;
            public byte BMDchgCellOT1;
            public byte BMDchgCellOT2;
            public byte BMDchgCellOT3;
            public byte BMDchgCellUT1;
            public byte BMDchgCellUT2;
            public byte BMDchgCellUT3;
            public byte BMDchgOverCur1;
            public byte BMDchgOverCur2;
            public byte BMDchgOverCur3;
            public byte BMDectError_DI1_PosRly;
            public byte BMDectError_DI1_PosRlyOpen;
            public byte BMDectError_DI2_Fuse;
            public byte BMDectError_DI3_NegRly;
            public byte BMDectError_DI3_NegRlyOpen;
            public byte BMDectError_DI4_PCS;
            public byte BMDectError_DI5_EMS;
            public byte BMDectError_DI6_Surge;
            public byte BMDectError_DI8_Breaker;
            public byte BMHardwareError;
            public byte BMIsoRlow1;
            public byte BMIsoRlow2;
            public byte BMIsoRlow3;
            public byte BMMeasureErrorCluVol;
            public byte BMMeasureErrorOtherTemp;
            public byte BMMeasureError_Temp;
            public byte BMMeasureError_Vol;
            public byte BMMeasureErrorHigh_InletTemp;
            public byte BMMeasureErrorHigh_OtherTemp;
            public byte BMMeasureErrorHigh_OutletTemp;
            public byte BMMeasureErrorHigh_Temp;
            public byte BMMeasureErrorLow_InletTemp;
            public byte BMMeasureErrorLow_OutTemp;
            public byte BMMeasureErrorOpen_Vol;
            public byte BMNVMError;
            public byte BMPwrSupOV1;
            public byte BMPwrSupUV1;
            public byte BMSelfCheckError;
            public byte BMSOChigh1;
            public byte BMSOChigh2;
            public byte BMSOChigh3;
            public byte BMSOClow1;
            public byte BMSOClow2;
            public byte BMSOClow3;
            public byte BMTempUpFast2;
            public byte BMThrRunaway;
            public UInt16 BMS_1P5V_MSR;
            public UInt16 BMS_5V_MSR;
            public UInt16 BMS_AD_HALL_Current;
            public byte BMS_AFE_MaxTemp;
            public byte BMS_AFE_MaxTempNum;
            public byte BMS_AFE_MinTemp;
            public byte BMS_AFE_MinTempNum;
            public UInt16 BMS_AFEMaxVolt;
            public UInt16 BMS_AFEMinVolt;
            public UInt16 BMS_AvgVolt;
            public UInt16 BMS_BattSOE;
            public byte BMS_BattSts;
            public UInt16 BMS_BattTrueSOC;
            public UInt16 BMS_BattVolt;
            public byte BMS_BCU_PCB_Temp;
            public UInt16 BMS_BusBarAvgTemp;
            public UInt16 BMS_BusBarMaxTemp;
            public UInt16 BMS_BusBarMinTemp;
            public byte BMS_BusBarNumMaxTemp;
            public byte BMS_BusBarNumMinTemp;
            public UInt16 BMS_Calib_DisSOC;
            public UInt16 BMS_Calib_SOE;
            public UInt16 BMS_Calib_TrueSOC;
            public UInt16 BMS_CAN_HALL_Curr;
            public UInt16 BMS_CellAvgTemp;
            public UInt16 BMS_CellDiffTemp;
            public UInt16 BMS_CellMaxSOC;
            public UInt16 BMS_CellMaxTemp1;
            public UInt16 BMS_CellMaxTemp2;
            public UInt16 BMS_CellMaxTemp3;
            public UInt16 BMS_CellMinSOC;
            public UInt16 BMS_CellMinTemp1;
            public UInt16 BMS_CellMinTemp2;
            public UInt16 BMS_CellMinTemp3;
            public UInt16 BMS_CellNumMaxTemp1;
            public UInt16 BMS_CellNumMaxTemp2;
            public UInt16 BMS_CellNumMaxTemp3;
            public UInt16 BMS_CellNumMinTemp1;
            public UInt16 BMS_CellNumMinTemp2;
            public UInt16 BMS_CellNumMinTemp3;
            public UInt16 BMS_CellVolt_type;
            public UInt16 BMS_CellVoltMax1;
            public UInt16 BMS_CellVoltMax2;
            public UInt16 BMS_CellVoltMax3;
            public UInt16 BMS_CellVoltMin1;
            public UInt16 BMS_CellVoltMin2;
            public UInt16 BMS_CellVoltMin3;
            public UInt16 BMS_Cluster_Curr;
            public byte BMS_ClusterTemp_type;
            public byte BMS_CSC_PCB_MaxTemp;
            public byte BMS_CSC_PCB_MaxTempNum;
            public byte BMS_CSC_PCB_MinTemp;
            public byte BMS_CSC_PCB_MinTempNum;
            public byte BMS_DI_HSD1Sts;
            public byte BMS_DI_HSD2Sts;
            public byte BMS_DI_HSD3Sts;
            public byte BMS_DI_LSD1Sts;
            public byte BMS_DI_LSD2Sts;
            public byte BMS_DI_LSD3Sts;
            public byte BMS_DI_LSD4Sts;
            public UInt16 BMS_DTCNumber;
            public byte BMS_EndTime_Day;
            public byte BMS_EndTime_Hour;
            public byte BMS_EndTime_Minute;
            public byte BMS_EndTime_Month;
            public byte BMS_EndTime_Second;
            public byte BMS_EndTime_Year;
            public byte BMS_EnvirNumTemp_Max;
            public byte BMS_EnvirNumTemp_Min;
            public UInt16 BMS_EnvirTemp_1;
            public UInt16 BMS_EnvirTemp_2;
            public UInt16 BMS_EnvirTemp_3;
            public UInt16 BMS_EnvirTemp_4;
            public UInt16 BMS_EnvirTemp_Max;
            public UInt16 BMS_EnvirTemp_Min;
            public UInt16 BMS_HALL_OUT_MSR;
            public UInt16 BMS_HALL12V_HIGH_FAULT_MSR;
            public UInt16 BMS_HSD_OUT1_FAULT_MSR;
            public UInt16 BMS_HSD_OUT2_FAULT_MSR;
            public UInt16 BMS_HSD_RLY_NEG_MSR;
            public UInt16 BMS_HSD_RLY_POS_MSR;
            public UInt16 BMS_HWVersion;
            public byte BMS_ID;
            public UInt16 BMS_InletAvgTemp;
            public UInt16 BMS_InletMaxTemp;
            public UInt16 BMS_InletMinTemp;
            public byte BMS_InletNumMaxTemp;
            public byte BMS_InletNumMinTemp;
            public UInt16 BMS_ISO_5V_MSR;
            public UInt16 BMS_IsolationR;
            public UInt16 BMS_IsolationR_Neg;
            public UInt16 BMS_IsolationR_Pos;
            public UInt16 BMS_LinkPOStoPackNEGVolt1;
            public UInt16 BMS_LinkPOStoPackNEGVolt2;
            public UInt16 BMS_LSD_RLY_NEG_MSR;
            public UInt16 BMS_LSD_RLY_POS_MSR;
            public UInt16 BMS_LV12V_MSR;
            public UInt16 BMS_LV24_MSR;
            public UInt16 BMS_NEG_HIGH_FAULT_MSR;
            public UInt16 BMS_NEG_relay_Dia_Curr;
            public byte BMS_NegRlyDriveCmd;
            public byte BMS_NumberAFEMaxVolt;
            public byte BMS_NumberAFEMinVolt;
            public UInt16 BMS_NumberCellVoltMax1;
            public UInt16 BMS_NumberCellVoltMax2;
            public UInt16 BMS_NumberCellVoltMax3;
            public UInt16 BMS_NumberCellVoltMin1;
            public UInt16 BMS_NumberCellVoltMin2;
            public UInt16 BMS_NumberCellVoltMin3;
            public UInt16 BMS_OutletAvgTemp;
            public UInt16 BMS_OutletMaxTemp;
            public UInt16 BMS_OutletMinTemp;
            public byte BMS_OutletNumMaxTemp;
            public byte BMS_OutletNumMinTemp;
            public UInt16 BMS_POS_HIGH_FAULT_MSR;
            public UInt16 BMS_POS_relay_Dia_Curr;
            public byte BMS_PosRlyDriveCmd;
            public UInt16 BMS_PRECHG_HIGH_FAULT_MSR;
            public UInt16 BMS_PRECHG_relay_Dia_Curr;
            public byte BMS_PreRlyDriveCmd;
            public byte BMS_Read_Type;
            public UInt16 BMS_RLY_POS_MSR;
            public byte BMS_RTC_Day;
            public byte BMS_RTC_Hour;
            public byte BMS_RTC_Minute;
            public byte BMS_RTC_Month;
            public byte BMS_RTC_Second;
            public UInt16 BMS_RTC_Year;
            public UInt16 BMS_Shunt_Current;
            public UInt16 BMS_ShuntTemp_1;
            public UInt16 BMS_SingleChgCapacity;
            public UInt16 BMS_SingleChgEnergy;
            public UInt16 BMS_SingleDchgCapacity;
            public UInt16 BMS_SingleDchgEnergy;
            public UInt16 BMS_SOC;
            public UInt16 BMS_SOE;
            public UInt16 BMS_SOH;
            
            public byte BMS_StartTime_Day;
            public byte BMS_StartTime_Hour;
            public byte BMS_StartTime_Minute;
            public byte BMS_StartTime_Month;
            public byte BMS_StartTime_Second;
            public byte BMS_StartTime_Year;
            public UInt64 BMS_SWVersion;
            public UInt32 BMS_TotalChgCapacity;
            public UInt32 BMS_TotalChgEnergy;
            public UInt32 BMS_TotalDchgCapacity;
            public UInt32 BMS_TotalDchgEnergy;
            public UInt16 BMS_VREF;
            public UInt16 BMS_Wakeup_MSR;
            public byte DV_BMS_Balane_Page;
            public byte EMS_NEG_Cont_Cmd;
            public byte EMS_NEG_Cont_Cmd_Valid;
            public byte EMS_POS_Cont_Cmd;
            public byte EMS_POS_Cont_Cmd_Valid;
            public byte EMS_PRECHG_Cont_Cmd;
            public byte EMS_PRECHG_Cont_Cmd_Valid;
            public byte EOL_DryCont1;
            public byte EOL_DryCont1_Res;
            public byte EOL_DryCont2;
            public byte EOL_DryCont2_Res;
            public byte EOL_FanCont;
            public byte EOL_GreenLight;
            public byte EOL_GreenLight_Res;
            public byte EOL_IsoDetCmd;
            public byte EOL_MainNegCont;
            public byte EOL_MainNegCont_Res;
            public byte EOL_MainPosCont;
            public byte EOL_MainPosCont_Res;
            public byte EOL_ModelCont;
            public byte EOL_ModelState;
            public byte EOL_PreCont;
            public byte EOL_PreCont_Res;
            public byte EOL_RedLight;
            public byte EOL_RedLight_Res;
            public byte EOL_ShuntRelease;
            public byte EOL_ShuntRelease_Res;
            public byte Green_Light_Sts;
            public byte ID_CFG_BMS;
            public byte ID_CFG_BMS_Res;
            public byte ID_CFG_EMS;
            public byte ID_CFG_EMS_Res;
            public UInt32 IP_VALUE_CAB_CAN;
            public UInt16 LINK_NEG_MsrVolt;
            public byte PowerupCmd;
            public byte PowerupCmd_Res;
            public byte PreDV;
            public byte PreDV_Res;
            public byte Red_Light_Sts;
            public byte Test_BMS_BSWDebugFr;

        }
        
        public struct pc_Calibration_observation_t
        {
            public byte device;
            public byte operation;
            public UInt16 signal_num;
            public uint signal_val;
            public byte crc_base;
            public byte crc8;
        };
        public enum CLB_SIGNALNUM
        {
            CLB_ORDER_WRITE_TEST_1 = 1,
            CLB_ORDER_WRITE_TEST_2,
            CLB_ORDER_WRITE_TEST_3,
            CLB_ORDER_WRITE_TEST_4,
            CLB_ORDER_WRITE_TEST_5,
            CLB_ORDER_WRITE_TEST_6,
            CLB_ORDER_WRITE_TEST_7,
            CLB_ORDER_WRITE_TEST_8,
            CLB_ORDER_WRITE_TEST_9,
            CLB_ORDER_WRITE_TEST_10,
            CLB_ORDER_WRITE_TEST_11,
            CLB_ORDER_WRITE_TEST_12,
            CLB_ORDER_WRITE_TEST_13,
            CLB_ORDER_WRITE_TEST_14,
            CLB_ORDER_WRITE_TEST_15,
            CLB_ORDER_WRITE_TEST_16,
            CLB_ORDER_WRITE_TEST_17,
            CLB_ORDER_WRITE_TEST_18,
            CLB_ORDER_WRITE_TEST_19,
            CLB_ORDER_WRITE_TEST_20,
            CLB_ORDER_WRITE_TEST_21,
            CLB_ORDER_WRITE_TEST_22,
            CLB_ORDER_WRITE_TEST_23,
            CLB_ORDER_WRITE_TEST_24,
            CLB_ORDER_WRITE_TEST_25,
            CLB_ORDER_WRITE_TEST_26,
            CLB_ORDER_WRITE_TEST_27,
            CLB_ORDER_WRITE_TEST_28,
            CLB_ORDER_WRITE_TEST_29,
            CLB_ORDER_WRITE_TEST_30,
            CLB_ORDER_READ_TEST_1,
            CLB_ORDER_READ_TEST_2,
            CLB_ORDER_READ_TEST_3,
            CLB_ORDER_READ_TEST_4,
            CLB_ORDER_READ_TEST_5,
            CLB_ORDER_READ_TEST_6,
            CLB_ORDER_READ_TEST_7,
            CLB_ORDER_READ_TEST_8,
            CLB_ORDER_READ_TEST_9,
            CLB_ORDER_READ_TEST_10,
            CLB_ORDER_READ_TEST_11,
            CLB_ORDER_READ_TEST_12,
            CLB_ORDER_READ_TEST_13,
            CLB_ORDER_READ_TEST_14,
            CLB_ORDER_READ_TEST_15,
            CLB_ORDER_READ_TEST_16,
            CLB_ORDER_READ_TEST_17,
            CLB_ORDER_READ_TEST_18,
            CLB_ORDER_READ_TEST_19,
            CLB_ORDER_READ_TEST_20,
            CLB_ORDER_READ_TEST_21,
            CLB_ORDER_READ_TEST_22,
            CLB_ORDER_READ_TEST_23,
            CLB_ORDER_READ_TEST_24,
            CLB_ORDER_READ_TEST_25,
            CLB_ORDER_READ_TEST_26,
            CLB_ORDER_READ_TEST_27,
            CLB_ORDER_READ_TEST_28,
            CLB_ORDER_READ_TEST_29,
            CLB_ORDER_READ_TEST_30,
            CLB_ORDER_SLAVE1_BALA_1 = 61,
            CLB_ORDER_SLAVE1_BALA_2,
            CLB_ORDER_SLAVE2_BALA_1,
            CLB_ORDER_SLAVE2_BALA_2,
            CLB_ORDER_SLAVE3_BALA_1,
            CLB_ORDER_SLAVE3_BALA_2,
            CLB_ORDER_SLAVE4_BALA_1,
            CLB_ORDER_SLAVE4_BALA_2,
            CLB_ORDER_SLAVE5_BALA_1,
            CLB_ORDER_SLAVE5_BALA_2,
            CLB_ORDER_SLAVE6_BALA_1,
            CLB_ORDER_SLAVE6_BALA_2,
            CLB_ORDER_SLAVE7_BALA_1,
            CLB_ORDER_SLAVE7_BALA_2,
            CLB_ORDER_SLAVE8_BALA_1,
            CLB_ORDER_SLAVE8_BALA_2,

            CLB_W_CELLOV_LV1 = 101,
            CLB_W_CELLOV_LV2,
            CLB_W_CELLOV_LV3,
            CLB_W_CELLUV_LV1,
            CLB_W_CELLUV_LV2,
            CLB_W_CELLUV_LV3,
            CLB_W_PACKOV_LV1,
            CLB_W_PACKOV_LV2,
            CLB_W_PACKOV_LV3,
            CLB_W_PACKUV_LV1,
            CLB_W_PACKUV_LV2,
            CLB_W_PACKUV_LV3,
            CLB_W_CLUSTEROV_LV1,
            CLB_W_CLUSTEROV_LV2,
            CLB_W_CLUSTEROV_LV3,
            CLB_W_CLUSTERUV_LV1,
            CLB_W_CLUSTERUV_LV2,
            CLB_W_CLUSTERUV_LV3,
            CLB_W_CELLVOLDIFF_LV1,
            CLB_W_CELLVOLDIFF_LV2,
            CLB_W_CELLVOLDIFF_LV3,
            CLB_W_PACKVOLDIFF_LV1,
            CLB_W_PACKVOLDIFF_LV2,
            CLB_W_PACKVOLDIFF_LV3,
            CLB_W_CLUSTERVOLDIFF_LV1,
            CLB_W_CLUSTERVOLDIFF_LV2,
            CLB_W_CLUSTERVOLDIFF_LV3,
            CLB_W_CLUSTERCHGCUR_LV1,
            CLB_W_CLUSTERCHGCUR_LV2,
            CLB_W_CLUSTERCHGCUR_LV3,
            CLB_W_CLUSTERDCHGCUR_LV1,
            CLB_W_CLUSTERDCHGCUR_LV2,
            CLB_W_CLUSTERDCHGCUR_LV3,
            CLB_W_CELLTEMPDIFF_LV1,
            CLB_W_CELLTEMPDIFF_LV2,
            CLB_W_CELLTEMPDIFF_LV3,
            CLB_W_ISORLOW_LV1,
            CLB_W_ISORLOW_LV3,
            CLB_W_CLUSTERCICUMFLUX_LV1,
            CLB_W_CLUSTERCICUMFLUX_LV2,
            CLB_W_CLUSTERCICUMFLUX_LV3,
            CLB_W_CELLSOEHIGHT_LV1,
            CLB_W_CELLSOEHIGHT_LV2,
            CLB_W_CELLSOEHIGHT_LV3,
            CLB_W_CELLSOELOW_LV1,
            CLB_W_CELLSOELOW_LV2,
            CLB_W_CELLSOELOW_LV3,
            CLB_W_PACKSOEHIGHT_LV1,
            CLB_W_PACKSOEHIGHT_LV2,
            CLB_W_PACKSOEHIGHT_LV3,
            CLB_W_PACKSOELOW_LV1,
            CLB_W_PACKSOELOW_LV2,
            CLB_W_PACKSOELOW_LV3,
            CLB_W_CLUSTERSOEHIGHT_LV1,
            CLB_W_CLUSTERSOEHIGHT_LV2,
            CLB_W_CLUSTERSOEHIGHT_LV3,
            CLB_W_CLUSTERSOELOW_LV1,
            CLB_W_CLUSTERSOELOW_LV2,
            CLB_W_CLUSTERSOELOW_LV3,
            CLB_W_CELLTEMPRATE_LV1,
            CLB_W_CELLTEMPRATE_LV2,
            CLB_W_CELLTEMPRATE_LV3,
            CLB_W_CELLCHGOT_LV1,
            CLB_W_CELLCHGOT_LV2,
            CLB_W_CELLCHGOT_LV3,
            CLB_W_CELLCHGUT_LV1,
            CLB_W_CELLCHGUT_LV2,
            CLB_W_CELLCHGUT_LV3,
            CLB_W_CELLDCHGOT_LV1,
            CLB_W_CELLDCHGOT_LV2,
            CLB_W_CELLDCHGOT_LV3,
            CLB_W_CELLDCHGUT_LV1,
            CLB_W_CELLDCHGUT_LV2,
            CLB_W_CELLDCHGUT_LV3,
            CLB_W_CLUSTERSOCHIGHT_LV1,
            CLB_W_CLUSTERSOCHIGHT_LV2,
            CLB_W_CLUSTERSOCHIGHT_LV3,
            CLB_W_CLUSTERSOCLOW_LV1,
            CLB_W_CLUSTERSOCLOW_LV2,
            CLB_W_CLUSTERSOCLOW_LV3,

            CLB_W_MAX = 500,
            CLB_W_EXT_DO_PosRelay_H = 501,
            CLB_W_EXT_DO_NegRelay_H,
            CLB_W_EXT_DO_PreRelay_H,
            CLB_W_EXT_DO_PosRelay_L,
            CLB_W_EXT_DO_NegRelay_L,
            CLB_W_PTA18_WAKEUP_HOLD,
            CLB_W_PTA19_UART2_DE,
            CLB_W_PTA20_UART0_DE,
            CLB_W_PTA21_NODE1_EN,
            CLB_W_PTD1_NODE2_EN,
            CLB_W_PTD0_NODE3_EN,
            CLB_W_PTE10_NODE4_EN,
            CLB_W_PTE13_200mAHSD_EN1,
            CLB_W_PTE5_200mAHSD_EN2,
            CLB_W_PTE4_200mAHSD_EN3,
            CLB_W_PTE14_200mAHSD_EN4,
            CLB_W_PTE9_12V_DCDC_EN,
            CLB_W_PTB20_HSDIC_OPENLODA_DIAG,
            CLB_W_PTB26_HSDIC_SEL,
            CLB_W_PTB3_HSDIC_SEH,
            CLB_W_PTB2_HSDIC_DIAG_EN,
            CLB_W_PTC18_HOLD_OE_EN,
            CLB_W_PTA17_DO_HSD_OUT1,
            CLB_W_PTD20_DO_HSD_OUT2,
            CLB_W_PTB16_DO_HSD_OUT3,
            CLB_W_PTD22_DO_LSD_OUT1,
            CLB_W_PTD4_DO_LSD_OUT2,
            CLB_W_PTD23_RELAY_DIAG1,
            CLB_W_PTB11_RELAY_DIAG2,
            CLB_W_PTB8_LINK_DIG_EN,
            CLB_W_PTE21_ISO_GND_EN2,
            CLB_W_PTE22_ISO_GND_EN1,
            CLB_W_PTE23_ISO_POS_EN,

            CLB_W_RTC_TIME = 550,
            CLB_W_RTC_DAY,

            CLB_W_FACINFO_CLUSTERCELLNUM =601,
            CLB_W_FACINFO_AFECELLNUM,
            CLB_W_FACINFO_PACKNUM,
            CLB_W_FACINFO_BMUCellNum,
            CLB_W_FACINFO_BMUAfeNum,
            CLB_W_FACINFO_SWVersion,
            CLB_W_FACINFO_HWVersion,
            CLB_W_FACINFO_SNNum,
            CLB_W_FACINFO_TEST6,
            CLB_W_FACINFO_TEST7,

            CLB_W_FACINFO_CRC32	= 701,
            CLB_W_AssignBMUaddr = 702,//bmu 分配地址
            CLB_W_OpenHightVol = 703,//上高压
            CLB_W_IsoDetEnable = 704,//绝缘监测开关

            /*
            CLB_ORDER_BMCELLDIFF1,
            CLB_ORDER_BMCHGCELLOT1,
            CLB_ORDER_BMPWRSUPUV1,
            CLB_ORDER_BMPWRSUPOV1,
            CLB_ORDER_BMCLUUV1,
            CLB_ORDER_BMCLUOV1,
            CLB_ORDER_BMBUSBAROT1,
            CLB_ORDER_BMCHGOVERCUR1,
            CLB_ORDER_BMDCHGCELLUT1,
            CLB_ORDER_BMCELLTEMPOVERDIFF1,
            CLB_ORDER_BMDCHGOVERCUR1,
            CLB_ORDER_BMISORLOW1,
            CLB_ORDER_BMSOCLOW1,
            CLB_ORDER_BMSOCHIGH1,
            CLB_ORDER_BMCELLOV1,
            CLB_ORDER_BMCELLUV1,
            CLB_ORDER_BMCELLDIFF2,
            CLB_ORDER_BMCHGCELLOT2,
            CLB_ORDER_BMCLUUV2,
            CLB_ORDER_BMCLUOV2,
            CLB_ORDER_BMBUSBAROT2,
            CLB_ORDER_BMCHGOVERCUR2,
            CLB_ORDER_BMCHGCELLUT1,
            CLB_ORDER_BMDCHGCELLOT1,
            CLB_ORDER_BMCELLTEMPOVERDIFF2,
            CLB_ORDER_BMTEMPUPFAST2,
            CLB_ORDER_BMDCHGOVERCUR2,
            CLB_ORDER_BMISORLOW2,
            CLB_ORDER_BMSOCLOW2,
            CLB_ORDER_BMSOCHIGH2,
            CLB_ORDER_BMCELLOV2,
            CLB_ORDER_BMCELLUV2,
            CLB_ORDER_BMCHGCELLOT3,
            CLB_ORDER_BMCLUUV3,
            CLB_ORDER_BMCLUOV3,
            CLB_ORDER_BMBUSBAROT3,
            CLB_ORDER_BMCHGOVERCUR3,
            CLB_ORDER_BMCHGCEKLLUT2,
            CLB_ORDER_BMDCHGCELLOT2,
            CLB_ORDER_BMDCHGCELLUT2,
            CLB_ORDER_BMCELLTEMPOVERDIFF3,
            CLB_ORDER_BMDCHGOVERCUR3,
            CLB_ORDER_BMISORLOW3,
            CLB_ORDER_BMSOCLOW3,
            CLB_ORDER_BMSOCHIGH3,
            CLB_ORDER_BMCELLOV3,
            CLB_ORDER_BMCELLUV3,
            CLB_ORDER_BMCELLDIFF3,
            CLB_ORDER_BMDECTERROR_DI2_FUSE,
            CLB_ORDER_BMDECTERROR_DI3_NEGRLYOPEN,
            CLB_ORDER_BMDECTERROR_DI3_NEGRLY,
            CLB_ORDER_BMDECTERROR_DI4_PCS,
            CLB_ORDER_BMDECTERROR_DI5_EMS,
            CLB_ORDER_BMCHGCELLUT3,
            CLB_ORDER_BMDCHGCELLOT3,
            CLB_ORDER_BMDCHGCELLUT3,
            CLB_ORDER_BMMEASUREERROR_OTHERTEMP,
            CLB_ORDER_BMCOMMERROR,
            CLB_ORDER_BMMEASUREERROROPEN_VOL,
            CLB_ORDER_BMMEASUREERROR_VOL,
            CLB_ORDER_BMMEASUREERRORHIGH_TEMP,
            CLB_ORDER_BMMEASUREERROR_TEMP,
            CLB_ORDER_BMDECTERROR_DI1_POSRLYOPEN,
            CLB_ORDER_BMDECTERROR_DI1_POSRLYCLOSE,
            CLB_ORDER_BMTHRRUNAWAY,
            CLB_ORDER_BMCANHALLOUTRANGE,
            CLB_ORDER_BMCANHALLZEROERROR,
            CLB_ORDER_BMCANSENSORERROR,
            CLB_ORDER_BMCANHALLERROR,
            CLB_ORDER_BMSELFCHECKERROR,
            CLB_ORDER_BMHARDWAREERROR,
            CLB_ORDER_BMMEASUREERRORHIGH_OTHERTEMP,
            CLB_ORDER_BMMEASUREERRORHIGH_OUTLETTEMP,
            CLB_ORDER_BMMEASUREERRORLOW_INLETTEMP,
            CLB_ORDER_BMMEASUREERRORHIGH_INLETTEMP,
            CLB_ORDER_BMBALANCEERROR,
            CLB_ORDER_BMCONTACTORPOWERRORHIGH,
            CLB_ORDER_BMCONTACTORPOWERROR,
            CLB_ORDER_BMMEASUREERROR_CLUVOL,
            CLB_ORDER_BMNVMERROR,
            CLB_ORDER_BMDECTERROR_DI6_SURGE,
            CLB_ORDER_BMDECTERROR_DI8_BREAKER,
            CLB_ORDER_BMMEASUREERRORLOW_OUTLETTEMP
            */
        }
        public string[] ControlFun = new string[33]
       {
            "主正高边继电器-501",
            "主负高边继电器-502",
            "预充继电器-503",
            "主正低边继电器-504",
            "主负低边继电器-505",
            "PTA18_WAKEUP_HOLD-506",
            "PTA19_UART2_DE-507",
            "PTA20_UART0_DE-508",

            "PTA21_NODE1_EN-509",
            "PTD1_NODE2_EN-510",
            "PTD0_NODE3_EN-511",
            "PTE10_NODE4_EN-512",
            "PTE13_200mAHSD_EN1-513",
            "PTE5_200mAHSD_EN2-514",
            "PTE4_200mAHSD_EN3-515",
            "PTE14_200mAHSD_EN4-516",
            "PTE9_12V_DCDC_EN-517",
            "PTB20_HSDIC_OPENLODA_DIAG-518",
            "PTB26_HSDIC_SEL-519",
            "PTB3_HSDIC_SEH-520",
            "PTB2_HSDIC_DIAG_EN-521",
            "PTC18_HOLD_OE_EN-522",
            "PTA17_DO_HSD_OUT1-523",
            "PTD20_DO_HSD_OUT2-524",
            "PTB16_DO_HSD_OUT3-525",
            "PTD22_DO_LSD_OUT1-526",
            "PTD4_DO_LSD_OUT2-527",
            "PTD23_RELAY_DIAG1-528",
            "PTB11_RELAY_DIAG2-529",
            "PTB8_LINK_DIG_EN-530",
            "PTE21_ISO_GND_EN2-531",
            "PTE22_ISO_GND_EN1-532",
            "PTE23_ISO_POS_EN-533",
    };

        public string[] faultInfostr = new string[80]
        {
            "Level1	 单体电压高",
            "Level2	 单体电压高",
            "Level3	 单体电压高",
            "Level1	 单体电压低",
            "Level2	 单体电压低",
            "Level3	 单体电压低",
            "Level1	 模块电压高",
            "Level2	 模块电压高",
            "Level3	 模块电压高",
            "Level1	 模块电压低",
            "Level2	 模块电压低",
            "Level3	 模块电压低",
            "Level1	 簇电压高",
            "Level2	 簇电压高",
            "Level3	 簇电压高",
            "Level1	 簇电压低",
            "Level2	 簇电压低",
            "Level3	 簇电压低",
            "Level1	 单体电压一致性极差大",
            "Level2	 单体电压一致性极差大",
            "Level3	 单体电压一致性极差大",
            "Level1	 模块电压一致性极差大",
            "Level2	 模块电压一致性极差大",
            "Level3	 模块电压一致性极差大",
            "Level1	 簇电压一致性极差大",
            "Level2	 簇电压一致性极差大",
            "Level3	 簇电压一致性极差大",
            "Level1	 簇充电电流大",
            "Level2	 簇充电电流大",
            "Level3	 簇充电电流大",
            "Level1	 簇放电电流大",
            "Level2	 簇放电电流大",
            "Level3	 簇放电电流大",
            "Level1	 单体温度一致性极差大",
            "Level2	 单体温度一致性极差大",
            "Level3	 单体温度一致性极差大",
            "Level1	 绝缘电阻低",
            //"Level2	 绝缘电阻低",
            "Level3	 绝缘电阻低",
            "Level1	 簇降环流大",
            "Level2	 簇降环流大",
            "Level3	 簇降环流大",
            "Level1	 单体SOE高",
            "Level2	 单体SOE高",
            "Level3	 单体SOE高",
            "Level1	 单体SOE低",
            "Level2	 单体SOE低",
            "Level3	 单体SOE低",
            "Level1	 模块SOE高",
            "Level2	 模块SOE高",
            "Level3	 模块SOE高",
            "Level1	 模块SOE低",
            "Level2	 模块SOE低",
            "Level3	 模块SOE低",
            "Level1	 簇SOE高",
            "Level2	 簇SOE高",
            "Level3	 簇SOE高",
            "Level1	 簇SOE低",
            "Level2	 簇SOE低",
            "Level3	 簇SOE低",
            "Level1	 单体温升速率",
            "Level2	 单体温升速率",
            "Level3	 单体温升速率",
            "Level1	 充电单体过温",
            "Level2	 充电单体过温",
            "Level3	 充电单体过温",
            "Level1	 充电单体欠温",
            "Level2	 充电单体欠温",
            "Level3	 充电单体欠温",
            "Level1	 放电单体过温",
            "Level2	 放电单体过温",
            "Level3	 放电单体过温",
            "Level1	 放电单体欠温",
            "Level2	 放电单体欠温",
            "Level3	 放电单体欠温",
            "Level1	 簇SOC高",
            "Level2	 簇SOC高",
            "Level3	 簇SOC高",
            "Level1	 簇SOC低",
            "Level2	 簇SOC低",
            "Level3	 簇SOC低"
        };
        public string[] faultInfostr0x1a0 = new string[64]
       {
            "供电电压欠压",
            "供电电压过压",
            "level1 铜排过温",
            "level2 铜排过温",
            "level3 铜排过温",
            "DI3主负接触器卡闭故障",
            "DI3主负接触器卡开故障",
            "DI2熔断器检测故障",
            "簇电压采集故障",
            "Ems通讯故障",
            "DI8断路器检测故障",
            "NVM检测故障",
            "硬件自检异常",
            "热失控",
            "DI1主正接触器卡开故障",
            "DI1主正接触器卡闭故障",
            "DI4PCS检测故障",
            "DI5EMS检测故障",
            "极柱温度采集回路低故障",
            "单体温度采集回路低故障",
            "单体电压采集故障",
            "单体电压采集开路故障",
            "单体温度采集回路高故障",
            "Debug内网通讯故障",
            "DI6浪涌检测故障",
            "主接触器供电高故障",
            "主接触器供电低故障",
            "CAN霍尔传感器故障",
            "CAN霍尔零漂故障",
            "CAN霍尔超范围故障",
            "CAN霍尔通讯故障",
            "均衡故障",
            "出水口温度采集回路低",
            "入水口温度采集回路低",
            "出水口温度采集回路高",
            "极柱温度采集回路高故障",
            "入水口温度采集回路高故障",
            "电池模块过压阈值异常",
            "单体欠压压阈值异常",
            "单体过压阈值异常",
            "簇放电过流阈值异常",
            "簇充电过流阈值异常",
            "簇电压一致性差过高阈值异常",
            "电池模块电压一致性差阈值异常",
            "单体电压一致性差过高阈值异常",
            "簇欠压阈值异常",
            "簇过压阈值异常",
            "电池模块欠压阈值异常",
            "簇SOE过高阈值异常",
            "电池模块SOE过低阈值异常",
            "电池模块SOE过高阈值异常",
            "单体SOE过低阈值异常",
            "单体SOE过高阈值异常",
            "簇环流过流阈值异常",
            "绝缘阻值阈值异常",
            "单体温度一致性极差阈值异常",
            "簇SOC过低阈值异常",
            "簇SOC过高阈值异常",
            "单体放电欠温阈值异常",
            "单体放电过温阈值异常",
            "单体充电欠温度阈值异常",
            "单体充电过温阈值异常",
            "单体温升过高阈值异常",
            "簇SOE过低阈值异常"
       };
        public struct CLB_SIGNALVAL
        {
            public UInt32 WriteTestVal_1;
            public UInt32 WriteTestVal_2;
            public UInt32 WriteTestVal_3;
            public UInt32 WriteTestVal_4;
            public UInt32 WriteTestVal_5;
            public UInt32 WriteTestVal_6;
            public UInt32 WriteTestVal_7;
            public UInt32 WriteTestVal_8;
            public UInt32 WriteTestVal_9;
            public UInt32 WriteTestVal_10;
            public UInt32 WriteTestVal_11;
            public UInt32 WriteTestVal_12;
            public UInt32 WriteTestVal_13;
            public UInt32 WriteTestVal_14;
            public UInt32 WriteTestVal_15;
            public UInt32 WriteTestVal_16;
            public UInt32 WriteTestVal_17;
            public UInt32 WriteTestVal_18;
            public UInt32 WriteTestVal_19;
            public UInt32 WriteTestVal_20;
            public UInt32 WriteTestVal_21;
            public UInt32 WriteTestVal_22;
            public UInt32 WriteTestVal_23;
            public UInt32 WriteTestVal_24;
            public UInt32 WriteTestVal_25;
            public UInt32 WriteTestVal_26;
            public UInt32 WriteTestVal_27;
            public UInt32 WriteTestVal_28;
            public UInt32 WriteTestVal_29;
            public UInt32 WriteTestVal_30;
            public UInt32 ReadTestVal_1;
            public UInt32 ReadTestVal_2;
            public UInt32 ReadTestVal_3;
            public UInt32 ReadTestVal_4;
            public UInt32 ReadTestVal_5;
            public UInt32 ReadTestVal_6;
            public UInt32 ReadTestVal_7;
            public UInt32 ReadTestVal_8;
            public UInt32 ReadTestVal_9;
            public UInt32 ReadTestVal_10;
            public UInt32 ReadTestVal_11;
            public UInt32 ReadTestVal_12;
            public UInt32 ReadTestVal_13;
            public UInt32 ReadTestVal_14;
            public UInt32 ReadTestVal_15;
            public UInt32 ReadTestVal_16;
            public UInt32 ReadTestVal_17;
            public UInt32 ReadTestVal_18;
            public UInt32 ReadTestVal_19;
            public UInt32 ReadTestVal_20;
            public UInt32 ReadTestVal_21;
            public UInt32 ReadTestVal_22;
            public UInt32 ReadTestVal_23;
            public UInt32 ReadTestVal_24;
            public UInt32 ReadTestVal_25;
            public UInt32 ReadTestVal_26;
            public UInt32 ReadTestVal_27;
            public UInt32 ReadTestVal_28;
            public UInt32 ReadTestVal_29;
            public UInt32 ReadTestVal_30;
            /*
            public UInt32 BMCellDiff1;
            public UInt32 BMChgCellOT1;
            public UInt32 BMPwrSupUV1;
            public UInt32 BMPwrSupOV1;
            public UInt32 BMCluUV1;
            public UInt32 BMCluOV1;
            public UInt32 BMBusbarOT1;
            public UInt32 BMChgOverCur1;
            public UInt32 BMDchgCellUT1;
            public UInt32 BMCelltempOverDiff1;
            public UInt32 BMDchgOverCur1;
            public UInt32 BMIsoRlow1;
            public UInt32 BMSOClow1;
            public UInt32 BMSOChigh1;
            public UInt32 BMCellOV1;
            public UInt32 BMCellUV1;
            public UInt32 BMCellDiff2;
            public UInt32 BMChgCellOT2;
            public UInt32 BMCluUV2;
            public UInt32 BMCluOV2;
            public UInt32 BMBusbarOT2;
            public UInt32 BMChgOverCur2;
            public UInt32 BMChgCellUT1;
            public UInt32 BMDchgCellOT1;
            public UInt32 BMCelltempOverDiff2;
            public UInt32 BMTempUpFast2;
            public UInt32 BMDchgOverCur2;
            public UInt32 BMIsoRlow2;
            public UInt32 BMSOClow2;
            public UInt32 BMSOChigh2;
            public UInt32 BMCellOV2;
            public UInt32 BMCellUV2;
            public UInt32 BMChgCellOT3;
            public UInt32 BMCluUV3;
            public UInt32 BMCluOV3;
            public UInt32 BMBusbarOT3;
            public UInt32 BMChgOverCur3;
            public UInt32 BMChgCellUT2;
            public UInt32 BMDchgCellOT2;
            public UInt32 BMDchgCellUT2;
            public UInt32 BMCelltempOverDiff3;
            public UInt32 BMDchgOverCur3;
            public UInt32 BMIsoRlow3;
            public UInt32 BMSOClow3;
            public UInt32 BMSOChigh3;
            public UInt32 BMCellOV3;
            public UInt32 BMCellUV3;
            public UInt32 BMCellDiff3;
            public UInt32 BMDectError_DI2_Fuse;
            public UInt32 BMDectError_DI3_NegRlyOpen;
            public UInt32 BMDectError_DI3_NegRly;
            public UInt32 BMDectError_DI4_PCS;
            public UInt32 BMDectError_DI5_EMS;
            public UInt32 BMChgCellUT3;
            public UInt32 BMDchgCellOT3;
            public UInt32 BMDchgCellUT3;
            public UInt32 BMMeasureError_OtherTemp;
            public UInt32 BMCommError;
            public UInt32 BMMeasureErrorOpen_Vol;
            public UInt32 BMMeasureError_Vol;
            public UInt32 BMMeasureErrorHigh_Temp;
            public UInt32 BMMeasureError_Temp;
            public UInt32 BMDectError_DI1_PosRlyOpen;
            public UInt32 BMDectError_DI1_PosRly;
            public UInt32 BMThrRunaway;
            public UInt32 BMCanHallOutRange;
            public UInt32 BMCanHallZeroError;
            public UInt32 BMCanSensorError;
            public UInt32 BMCanHallError;
            public UInt32 BMSelfCheckError;
            public UInt32 BMHardwareError;
            public UInt32 BMMeasureErrorHigh_OtherTemp;
            public UInt32 BMMeasureErrorHigh_OutletTemp;
            public UInt32 BMMeasureErrorLow_InletTemp;
            public UInt32 BMMeasureErrorHigh_InletTemp;
            public UInt32 BmbalanceError;
            public UInt32 BMContactorPowErrorHigh;
            public UInt32 BMContactorPowError;
            public UInt32 BMMeasureError_CluVol;
            public UInt32 BMNVMError;
            public UInt32 BMDectError_DI6_Surge;
            public UInt32 BMDectError_DI8_Breaker;
            public UInt32 BMMeasureErrorLow_OutTemp;
            */
           
        }

        /// <summary>
        /// 电压温度等级阈值
        /// </summary>
        public struct CellLevel_s
        {
            public UInt16 VOL_LV1max;
            public UInt16 VOL_LV1min;
            public UInt16 VOL_LV2max;
            public UInt16 VOL_LV2min;
            public UInt16 VOL_LV3max;
            public UInt16 VOL_LV3min;
            public UInt16 VOL_LV4max;
            public UInt16 VOL_LV4min;
            public UInt16 TEMP_LV1max;
            public UInt16 TEMP_LV1min;
            public UInt16 TEMP_LV2max;
            public UInt16 TEMP_LV2min;
            public UInt16 TEMP_LV3max;
            public UInt16 TEMP_LV3min;
            public UInt16 TEMP_LV4max;
            public UInt16 TEMP_LV4min;
        }
        public byte Clb_unpack_right_shift_u8(byte value, byte shift, byte mask)
        {
            return (byte)((byte)(value & mask) >> shift);
        }
        public UInt16 Clb_unpack_left_shift_u16(byte value, byte shift, byte mask)
        {
            return (UInt16)((UInt16)(value & mask) << shift);
        }
        public UInt32 Clb_unpack_left_shift_u32(byte value, byte shift, byte mask)
        {
            return ((UInt32)(value & mask) << shift);
        }
    }
    class connect
    {
        public MySqlConnection conn = null;//连接对象
        public MySqlCommand comm = null;//语句执行对象
        public MySqlDataReader dr = null;//语句执行结果数据对象

        public void MySLQLload()
        {
            //直接写链接语句，比较容易出错
            //conn = new MySqlConnection(
            //    "Database = data;Server = localhost;Port = 3306;Password = " + pwd + ";UserID = " + uid + ";charset = utf8mb4");
            //conn.Open();

            //使用Builder写语句，实现分段
            //与数据库连接的信息
            MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder();
            //数据库连接时的用户名，可以用pid
            builder.UserID = "rjet";
            //数据库连接时的密码，可以用pwd
            builder.Password = "Abc18620993137";
            //数据库连接时的服务器地址
            builder.Server = "rm-bp1ih51o2naau85dp8o.mysql.rds.aliyuncs.com";
            //要连接的数据库986
            builder.Database = "rjet_test_01";
            //定义与数据连接的链接
            conn = new MySqlConnection(builder.ConnectionString);
            //打开这个链接
            conn.Open();
        }
    }
}
